﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KendoMvcUI.Core;
using KendoMvcUI.Common;
using System.Web.Mvc;

namespace KendoMvcUI.UI
{
    public class RangeSlider:KendoUIBase
    {
        public RangeSlider(KendoUIControlSettings settings,ViewContext context,IViewDataContainer container)
            :base(settings,context,container)
        { }
    }
    public class RangeSliderSettings : KendoUIControlSettings
    {
        public RangeSliderSettings()
            : base("kendoRangeSlider")
        { }
        /// <summary>
        /// default: 5
        /// The delta with which the value will change when the user presses 
        /// the Page Up or Page Down key (the drag handle must be focused). 
        /// Note: The allied largeStep will also set large tick for every large step.
        /// </summary>
        public int? LargeStep { get; set; }
        public int? Max { get; set; }
        public int? Min { get; set; }
        /// <summary>
        /// The orientation of a RangeSlider; "horizontal" or "vertical".
        /// </summary>
        public string Orientation { get; set; }
        public int? SelectionEnd { get; set; }
        public int? SelectionStart { get; set; }
        public int? SmallStep { get; set; }
        /// <summary>
        /// "topLeft","bottomRight","both","none"
        /// </summary>
        public string TickPlacement { get; set; }
        [PropertySetting(IsIngoreForJavaScript=true)]
        public Action<TooltipSettings> Tooltip { get; set; }

        #region 事件
        public string On_Change { get; set; }
        public string On_Slide{ get; set; }
        #endregion

        public override string ToJsSettings()
        {
            var js= base.ToJsSettings();
            if (!js.EndsWith(","))
                js += ",";
            if(Tooltip!=null)
            {
                TooltipSettings tooltip = new TooltipSettings();
                Tooltip(tooltip);
                js += tooltip.ToString() + ",";
            }
            return js.TrimEnd(',');
        }
    }
    public class TooltipSettings
    {
        public bool? Enable { get; set; }
        public string Format { get; set; }
        public string Template { get; set; }
        public override string ToString()
        {
            string js = "";
            if (Enable.HasValue)
                js += "enable:{0},".Formator(Enable.Value.ToString().LowercaseFirst());
            if (!Format.IsNullOrWhiteSpace())
                js += "format:'{0}',".Formator(Format);
            if (!Template.IsNullOrWhiteSpace())
                js += "template:'{0}',".Formator(Template);

            return "tooltip:{"+js.TrimEnd(',')+"}";
        }
    }
}
